package com.google.code.cakedroid.core;

import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Reader;
import java.net.URL;
import java.net.URLConnection;

/**
 *IO Core Class
 *@author androidyue
 *Last Modified:2011-12-8    ����10:14:16
 */
public class IOCore {
	
	/**
	 * Get InputStream from a given url address
	 * @param urlString  the destination url address
	 * @return  InputStream from the given url address
	 * @throws IOException if the internet is not available or something wrong.
	 */
	public  InputStream getInputStreamFromURL(String urlString) throws IOException{
		URL url=new URL(urlString);
		URLConnection urlConnection=url.openConnection();
		return urlConnection.getInputStream();
	}
	
	/**
	 * Get InputStream Reader from given url
	 * @param urlString the destination url address
	 * @return	InputStreamReader from the given url address
	 * @throws IOException	if the internet is not available or something wrong. 
	 */
	public Reader getInputStreamReaderFromUrl(String urlString) throws IOException{
		InputStream inputStream=this.getInputStreamFromURL(urlString);
		Reader reader=new InputStreamReader(inputStream);
		return reader;
	}
	
}
